package JZOffer;

public class _17 {
    class Solution {
        public void Mirror(TreeNode root) {
            if (root == null) return;
            if (root.left == null && root.right == null) return;
            TreeNode temp = root.left;
            root.left = root.right;
            root.right = temp;

            if (root.left != null) Mirror(root.left);
            if (root.right != null) Mirror(root.right);
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        _17 c = new _17();
        _17.Solution s = c.getSolution();
        TreeNode L1 = new TreeNode(3);
        TreeNode L2 = new TreeNode(4);
        TreeNode L3 = new TreeNode(5);
        TreeNode L4 = new TreeNode(6);
        TreeNode L5 = new TreeNode(7);
        L1.left = L2;
        L1.right = L3;
        L2.left = L4;
        L2.right = L5;
        TreeNode R1 = new TreeNode(4);
        TreeNode R2 = new TreeNode(6);
        TreeNode R3 = new TreeNode(7);
        R1.left = R2;
        R1.right = R3;

        s.Mirror(L1);
        System.out.println("finish");

    }
}
